/*
 * timer.h
 */

#ifndef TIMED_CONTROLLER_H_
#define TIMED_CONTROLLER_H_

#include <stdlib.h>
#include <time.h>
#include "action.h"

/*
 * A struct for a node in the timed controller object.
 */
struct timed_controller_node {
    action *act;
    struct timed_controller_node *next;
    struct timed_controller_node *previous;
    time_t delay;
};

/*
 * A struct for the object representing the entire timed controller queue.
 */
struct timed_controller_object {
    struct timed_controller_node *head;
    struct timed_controller_node *tail;
};

/*
 * Returns 1 (true) if the timed controller has been initialized and is able to
 * accept actions.
 */
int timed_controller_create();

/*
 * Frees the timed controller structs and uninitializes.
 * Will print a warning message to stderr if timed controller is not
 * initialized.
 */
void timed_controller_free();

/*
 * Adds the given action to the timed controller queue, to be executed the given
 * delay (in seconds) after the current time the action was received.
 * Will print a warning message to stderr if timed controller is not
 * initialized.
 */
void timed_controller_add(action *a, unsigned int delay);

#endif
